﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DataAccess;
using DataAccess.Exceptions;
using Model;

namespace Business.WPF
{
    public class SearchStudentsManager
    {
        public Collection<Student> SearchStudentsByName(string name)
        {
            try
            {
                if (String.IsNullOrEmpty(name))
                    return StudentDataAccess.GetAllStudents();
                else
                    return StudentDataAccess.GetStudentsByName(name);
            }
            catch (Exception ex)
            {
                throw new BusinessException("Error: " + ex.Message);
            }
        }
        public Collection<Student> SearchStudentsByID(string id)
        {
            try
            {
                if (String.IsNullOrEmpty(id))
                    return StudentDataAccess.GetAllStudents();
                else
                    return StudentDataAccess.GetStudentsByID(Convert.ToInt32(id));
            }
            catch (Exception ex)
            {
                throw new BusinessException("Error: " + ex.Message);
            }
        }
    }
}
